package patterns;

import lombok.Data;

public class LearnStrategy {
    public static void main(String[] args) {
        Client c1 = new Client("CHR", new AliPay());
        Client c2 = new Client("RHC", new WeChatPay());
        c1.pay.pay();
        c2.pay.pay();
    }
}

@Data
class Client {
    String name;
    Way2Pay pay;

    public Client(String name, Way2Pay pay) {
        this.name = name;
        this.pay = pay;
    }
}

interface Way2Pay {
    void pay();
}

class WeChatPay implements Way2Pay {
    @Override
    public void pay() {
        System.out.println("使用微信支付");
    }
}

class AliPay implements Way2Pay {
    @Override
    public void pay() {
        System.out.println("使用支付宝支付");
    }
}

